 
#include "../../server/rpc_server.hpp"
#include "../../common/dispatcher.hpp"

void Add(const Json::Value &req,Json::Value &rsp)
{
    int num1=req["num1"].asInt();
    int num2=req["num2"].asInt();
    rsp=num1+num2;
}
int main()
{
    std::unique_ptr<myrpc::server::ServiceDescribeFactory> desc_factory(new myrpc::server::ServiceDescribeFactory());
    desc_factory->setMethodName("Add");
    
    desc_factory->setParamDesc("num1",myrpc::server::VType::INTEGRAL);
    desc_factory->setParamDesc("num2",myrpc::server::VType::INTEGRAL);
    desc_factory->setReturnType(myrpc::server::VType::INTEGRAL);
    desc_factory->setCallback(Add);


    myrpc::server::RpcServer server(myrpc::Address("127.0.0.1",9090),true,myrpc::Address("127.0.0.1",8080));

    server.registerMethod(desc_factory->build());
    server.start();
    return 0;
}